package cc.alcina.template.cs.persistent;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Lob;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import org.hibernate.annotations.Type;

import cc.alcina.framework.common.client.csobjects.SearchResult;
import cc.alcina.framework.common.client.logic.domaintransform.spi.AccessLevel;
import cc.alcina.framework.common.client.logic.reflection.BeanInfo;
import cc.alcina.framework.common.client.logic.reflection.CustomiserInfo;
import cc.alcina.framework.common.client.logic.reflection.DisplayInfo;
import cc.alcina.framework.common.client.logic.reflection.NamedParameter;
import cc.alcina.framework.common.client.logic.reflection.ObjectPermissions;
import cc.alcina.framework.common.client.logic.reflection.Permission;
import cc.alcina.framework.common.client.logic.reflection.VisualiserInfo;
import cc.alcina.framework.gwt.client.gwittir.customiser.DomainObjectIdRefCustomiser;
import cc.alcina.framework.gwt.client.gwittir.customiser.ExpandableLabelCustomiser;

import com.totsp.gwittir.client.beans.annotations.Introspectable;

/**
 * Logging generated by hbm2java
 */

@Entity
@Table(name = "logging", schema = "public")
@BeanInfo(displayNamePropertyName = "createdOn")
@SequenceGenerator(allocationSize=1,name = "logging_id_seq", sequenceName = "logging_id_seq")
@ObjectPermissions(create = @Permission(access = AccessLevel.ROOT), read = @Permission(access = AccessLevel.ADMIN), write = @Permission(access = AccessLevel.ADMIN), delete = @Permission(access = AccessLevel.ROOT))
@Introspectable
public class LogRecord extends DomainBase implements SearchResult {
	private long id;

	private Date createdOn;

	private String text;

	private Long userId;

	private String componentKey;

	public LogRecord() {
	}

	public LogRecord(long id) {
		this.id = id;
	}

	public LogRecord(long id, Date createdOn, String text, Long userId,
			String componentKey) {
		this.id = id;
		this.createdOn = createdOn;
		this.text = text;
		this.userId = userId;
		this.componentKey = componentKey;
	}

	@Id
	@Column(name = "id", unique = true, nullable = false)
	@GeneratedValue(generator = "logging_id_seq")
	public long getId() {
		return this.id;
	}

	public void setId(long id) {
		this.id = id;
	}

	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "created_on", length = 29)
	@VisualiserInfo(displayInfo = @DisplayInfo(name = "Date", orderingHint = 10))
	public Date getCreatedOn() {
		return this.createdOn;
	}

	public void setCreatedOn(Date createdOn) {
		this.createdOn = createdOn;
	}

	@Column(name = "text")
	@VisualiserInfo(displayInfo = @DisplayInfo(name = "Text"))
	@CustomiserInfo(customiserClass = ExpandableLabelCustomiser.class)
	@Lob
	@Type(type="org.hibernate.type.StringClobType")
	public String getText() {
		return this.text;
	}

	public void setText(String text) {
		this.text = text;
	}

	@Column(name = "user_id")
	@VisualiserInfo(displayInfo = @DisplayInfo(name = "User", orderingHint = 30))
	@CustomiserInfo(customiserClass = DomainObjectIdRefCustomiser.class, parameters = { @NamedParameter(name = DomainObjectIdRefCustomiser.TARGET_CLASS, classValue = AlcinaTemplateUser.class) })
	public Long getUserId() {
		return this.userId;
	}

	public void setUserId(Long userId) {
		this.userId = userId;
	}

	@Column(name = "component_key")
	@VisualiserInfo(displayInfo = @DisplayInfo(name = "Key", orderingHint = 20))
	public String getComponentKey() {
		return this.componentKey;
	}

	public void setComponentKey(String componentKey) {
		this.componentKey = componentKey;
	}
}
